﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Data;
using System.Windows;
using System.Windows.Controls;

namespace OpenFrameworkCore.Controls
{
	public class BasicControlContainer : OpenFrameworkCore.Controls.ControlContainerBase
	{
		/// <summary>
		/// 생성자
		/// </summary>
		public BasicControlContainer() :
			base()
		{
			DefaultStyleKey = typeof(BasicControlContainer);
		}

		/// <summary>
		/// InitBinding 오버라이드
		/// </summary>
		protected override void  InitContextToElementBinding()
		{
			base.InitContextToElementBinding();

			// Width를 바인딩합니다.
			Binding widthBinding = new Binding("Width");
			widthBinding.Source = ControlContainerContext;
			widthBinding.Mode = BindingMode.TwoWay;
			SetBinding(WidthProperty, widthBinding);

			// Height를 바인딩합니다.
			Binding heightBinding = new Binding("Height");
			heightBinding.Source = ControlContainerContext;
			heightBinding.Mode = BindingMode.TwoWay;
			SetBinding(HeightProperty, heightBinding);
		}

		/// <summary>
		/// ClearBinding 오버라이드
		/// </summary>
		protected override void ClearContextToElementBinding()
		{
			base.ClearContextToElementBinding();

			ClearValue(WidthProperty);
			ClearValue(HeightProperty);
		}
	}
}
